package com.luboyan.CBillbill.controller;

import com.luboyan.CBillbill.advice.TokenVerify;
import com.luboyan.CBillbill.dao.user.auth.UserAuthorities;
import com.luboyan.CBillbill.service.user.auth.UserAuthService;
import com.luboyan.CBillbill.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户所有权限管理控制
 */
@RestController
@RequestMapping("users")
public class UserAuthController {

    @Autowired
    private TokenVerify tokenVerify;

    @Autowired
    private UserAuthService userAuthService;

    /**
     * 获取用户所拥有的所有权限
     */
    @GetMapping("/authorities")
    public Result<UserAuthorities> getUserAuthorities(){
        Long userId = tokenVerify.getCurrentUserId();
        UserAuthorities userAuthorities = userAuthService.getUserAuthorities(userId);
        return new Result<>(userAuthorities);
    }

    //一些待完善的：大会员权限；等级系统权限没有全部添加；
}
